<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <h:outputStylesheet name="css/behind.css"/>

    </h:head>
    <h:body id="mainbody">
        <p:messages redisplay="false" showDetail="true" showSummary="true" autoUpdate="true" closable="true"/>

        <p:tabView id="tabview" activeIndex="#{creditView.activeIndex}">
            <p:tab title="Company">

                <p:panel  header="Create Company">
                    <p:messages autoUpdate="true" showDetail="true" showSummary="true" closable="true" redisplay="false" />
                    <h:form id="companyForm">
                        <h1><h:outputText value="Create"/></h1>
                        <p:panelGrid columns="2" >
                            <p:outputLabel value="Name:" for="name"/>
                            <p:inputText id="name" value="#{companyAction.company.name}" title="Name"  required="true"/>
                            <p:outputLabel value="Recharge Code:" for="rechargeCode"/>
                            <p:inputText id="rechargeCode" value="#{companyAction.company.rechargeCode}" title="RechargeCode"/>

                            <p:outputLabel value="Prefix Code:" for="prefixCode" />
                            <p:inputText id="prefixCode" value="#{companyAction.company.prefixCode}" title="PrefixCode" />

                            <p:commandButton update="@form" value="Create" action="#{companyAction.saveCompany()}" ajax="false"/>
                        </p:panelGrid>
                    </h:form>
                    <h:form>
                        <h1><h:outputText value="List Of Companies"/></h1>
                        <p:dataTable value="#{companyView.companies}" var="item">
                            <p:column headerText="actions">
                                <p:commandButton value="delete" action="#{companyDenominationAction.deleteCompanyValue(item.id)}" ajax="false"/>
                                <p:commandButton value="edit" action="#{companyDenominationAction.updateCompanyDetails(item.id)}" ajax="false" />
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Name"/>
                                </f:facet>
                                <h:outputText value="#{item.name}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Recharge Code"/>
                                </f:facet>
                                <h:outputText value="#{item.rechargeCode}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Prefix Code"/>
                                </f:facet>
                                <h:outputText value="#{item.prefixCode}"/>
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </p:panel>

            </p:tab>
            <p:tab title="Currency">
                <p:panel>
                    <p:messages autoUpdate="true" showDetail="true" showSummary="true" closable="true" redisplay="false"/>

                    <h:form id="currecyForm">
                        <p:panelGrid columns="2">
                            <p:outputLabel value="Currency:" for="currency" />
                            <p:inputText id="currency" value="#{denominationAction.denomination.currency}" />
                            <p:outputLabel value="Amount: " for="amount" />
                            <p:inputText  required="true" id="amount" value="#{denominationAction.denomination.amount}" />

                            <p:commandButton update="@form" value="Create" action="#{denominationAction.saveDenomination()}" ajax="false"/>
                        </p:panelGrid>
                    </h:form>
                </p:panel>
            </p:tab>
            <p:tab title="Voucher">
                <p:panel>
                    <p:messages autoUpdate="true" showDetail="true" showSummary="true" closable="true" redisplay="false"/>
                    <h:form id="voucherForm">
                        <p:panelGrid columns="2">
                            <p:outputLabel value="Select Network Operator" />
                            <p:selectOneMenu  value="#{companyDenominationAction.selectedCompany}" >
                                <f:selectItems value="#{companyView.companies}" var="comp"
                                               itemLabel="#{comp.name}" itemValue="#{comp.id}" />
                            </p:selectOneMenu>
                            <p:outputLabel value="Select Amount" />
                            <p:selectOneMenu value="#{companyDenominationAction.selectedDenomination}" >
                                <f:selectItems value="#{denominationView.denominations}" var="denom"
                                               itemLabel="#{denom.currency}-#{denom.amount}" itemValue="#{denom.id}" />
                            </p:selectOneMenu>
                            <p:commandButton value="Save"  update="@form"
                                             action="#{companyDenominationAction.saveCompanyDenomination()}" ajax="false"/>
                        </p:panelGrid>
                    </h:form>
                </p:panel>
            </p:tab>
            <p:tab id="tabCredit" title="Credit">

                <p:panel id="tabCreditPanel" header="Create Credit" >
                    <ui:include src="credit.xhtml"/>
                </p:panel>
            </p:tab>
        </p:tabView>
    </h:body>
</html>

